3.1.3 \(\int \frac {\sin ^2(x)}{i+\tan (x)} \, dx\) [3]

Optimal. Leaf size=50 \[ -\frac {i x}{8}-\frac {i}{8 (i-\tan (x))}-\frac {1}{8 (i+\tan (x))^2}-\frac {i}{4 (i+\tan (x))} \]

[Out]

-1/8*I*x-1/8*I/(I-tan(x))-1/8/(I+tan(x))^2-1/4*I/(I+tan(x))

________________________________________________________________________________________

Rubi [A]
time = 0.04, antiderivative size = 50, normalized size of antiderivative = 1.00, number of steps used = 5, number of rules used = 4, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.308, Rules used = {3597, 862, 90, 209} \begin {gather*} -\frac {i x}{8}-\frac {i}{8 (-\tan (x)+i)}-\frac {i}{4 (\tan (x)+i)}-\frac {1}{8 (\tan (x)+i)^2} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[Sin[x]^2/(I + Tan[x]),x]

[Out]

(-1/8*I)*x - (I/8)/(I - Tan[x]) - 1/(8*(I + Tan[x])^2) - (I/4)/(I + Tan[x])

Rule 90

Int[((a_.) + (b_.)*(x_))^(m_.)*((c_.) + (d_.)*(x_))^(n_.)*((e_.) + (f_.)*(x_))^(p_.), x_Symbol] :> Int[ExpandI
ntegrand[(a + b*x)^m*(c + d*x)^n*(e + f*x)^p, x], x] /; FreeQ[{a, b, c, d, e, f, p}, x] && IntegersQ[m, n] &&
(IntegerQ[p] || (GtQ[m, 0] && GeQ[n, -1]))

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 862

Int[((d_) + (e_.)*(x_))^(m_)*((f_.) + (g_.)*(x_))^(n_)*((a_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :> Int[(d + e*x)
^(m + p)*(f + g*x)^n*(a/d + (c/e)*x)^p, x] /; FreeQ[{a, c, d, e, f, g, m, n}, x] && NeQ[e*f - d*g, 0] && EqQ[c
*d^2 + a*e^2, 0] && (IntegerQ[p] || (GtQ[a, 0] && GtQ[d, 0] && EqQ[m + p, 0]))

Rule 3597

Int[sin[(e_.) + (f_.)*(x_)]^(m_)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n_), x_Symbol] :> Dist[b/f, Subst[Int
[x^m*((a + x)^n/(b^2 + x^2)^(m/2 + 1)), x], x, b*Tan[e + f*x]], x] /; FreeQ[{a, b, e, f, n}, x] && IntegerQ[m/
2]

Rubi steps

\begin {align*} \int \frac {\sin ^2(x)}{i+\tan (x)} \, dx &=\text {Subst}\left (\int \frac {x^2}{(i+x) \left (1+x^2\right )^2} \, dx,x,\tan (x)\right )\\ &=\text {Subst}\left (\int \frac {x^2}{(-i+x)^2 (i+x)^3} \, dx,x,\tan (x)\right )\\ &=\text {Subst}\left (\int \left (-\frac {i}{8 (-i+x)^2}+\frac {1}{4 (i+x)^3}+\frac {i}{4 (i+x)^2}-\frac {i}{8 \left (1+x^2\right )}\right ) \, dx,x,\tan (x)\right )\\ &=-\frac {i}{8 (i-\tan (x))}-\frac {1}{8 (i+\tan (x))^2}-\frac {i}{4 (i+\tan (x))}-\frac {1}{8} i \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (x)\right )\\ &=-\frac {i x}{8}-\frac {i}{8 (i-\tan (x))}-\frac {1}{8 (i+\tan (x))^2}-\frac {i}{4 (i+\tan (x))}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.11, size = 39, normalized size = 0.78 \begin {gather*} -\frac {i (3+\cos (2 x)-3 i \sin (2 x)+2 \text {ArcTan}(\tan (x)) (i+\tan (x)))}{16 (i+\tan (x))} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[Sin[x]^2/(I + Tan[x]),x]

[Out]

((-1/16*I)*(3 + Cos[2*x] - (3*I)*Sin[2*x] + 2*ArcTan[Tan[x]]*(I + Tan[x])))/(I + Tan[x])

________________________________________________________________________________________

Maple [A]
time = 0.11, size = 47, normalized size = 0.94

method result size
risch \(-\frac {i x}{8}+\frac {{\mathrm e}^{4 i x}}{32}-\frac {\cos \left (2 x \right )}{8}\) \(19\)
default \(-\frac {i}{4 \left (i+\tan \left (x \right )\right )}-\frac {1}{8 \left (i+\tan \left (x \right )\right )^{2}}+\frac {\ln \left (i+\tan \left (x \right )\right )}{16}+\frac {i}{8 \tan \left (x \right )-8 i}-\frac {\ln \left (\tan \left (x \right )-i\right )}{16}\) \(47\)
norman \(\frac {-\frac {1}{4}+\frac {x \tan \left (\frac {x}{2}\right )}{2}+i x \tan \left (x \right ) \tan \left (\frac {x}{2}\right )-\frac {\left (\tan ^{4}\left (\frac {x}{2}\right )\right )}{4}-\frac {\left (\tan ^{2}\left (\frac {x}{2}\right )\right )}{2}+\frac {i \tan \left (x \right ) \left (\tan ^{2}\left (\frac {x}{2}\right )\right )}{4}-\frac {i x \left (\tan ^{4}\left (\frac {x}{2}\right )\right )}{8}-\frac {x \tan \left (x \right ) \left (\tan ^{4}\left (\frac {x}{2}\right )\right )}{4}-\frac {3 i \tan \left (x \right ) \left (\tan ^{4}\left (\frac {x}{2}\right )\right )}{8}-\frac {3 i x \left (\tan ^{2}\left (x \right )\right )}{8}-\frac {i x}{8}-\frac {3 i x \left (\tan ^{2}\left (x \right )\right ) \left (\tan ^{4}\left (\frac {x}{2}\right )\right )}{8}+\frac {x \left (\tan ^{2}\left (x \right )\right ) \left (\tan ^{3}\left (\frac {x}{2}\right )\right )}{2}-\frac {x \left (\tan ^{2}\left (x \right )\right ) \tan \left (\frac {x}{2}\right )}{2}-\frac {5 i x \left (\tan ^{2}\left (\frac {x}{2}\right )\right )}{4}+\frac {3 x \tan \left (x \right ) \left (\tan ^{2}\left (\frac {x}{2}\right )\right )}{2}-i x \tan \left (x \right ) \left (\tan ^{3}\left (\frac {x}{2}\right )\right )+\frac {i x \left (\tan ^{2}\left (x \right )\right ) \left (\tan ^{2}\left (\frac {x}{2}\right )\right )}{4}-\frac {x \tan \left (x \right )}{4}-\frac {\tan \left (x \right ) \tan \left (\frac {x}{2}\right )}{2}-\frac {x \left (\tan ^{3}\left (\frac {x}{2}\right )\right )}{2}-\frac {3 i \tan \left (x \right )}{8}+i \tan \left (\frac {x}{2}\right )-i \left (\tan ^{3}\left (\frac {x}{2}\right )\right )+\frac {\tan \left (x \right ) \left (\tan ^{3}\left (\frac {x}{2}\right )\right )}{2}}{\left (1+\tan ^{2}\left (\frac {x}{2}\right )\right )^{2} \left (\tan ^{2}\left (x \right )+1\right )}\) \(248\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(x)^2/(I+tan(x)),x,method=_RETURNVERBOSE)

[Out]

-1/4*I/(I+tan(x))-1/8/(I+tan(x))^2+1/16*ln(I+tan(x))+1/8*I/(tan(x)-I)-1/16*ln(tan(x)-I)

________________________________________________________________________________________

Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: RuntimeError} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2/(I+tan(x)),x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative e
xponent.

________________________________________________________________________________________

Fricas [A]
time = 0.32, size = 25, normalized size = 0.50 \begin {gather*} \frac {1}{32} \, {\left (-4 i \, x e^{\left (2 i \, x\right )} + e^{\left (6 i \, x\right )} - 2 \, e^{\left (4 i \, x\right )} - 2\right )} e^{\left (-2 i \, x\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2/(I+tan(x)),x, algorithm="fricas")

[Out]

1/32*(-4*I*x*e^(2*I*x) + e^(6*I*x) - 2*e^(4*I*x) - 2)*e^(-2*I*x)

________________________________________________________________________________________

Sympy [A]
time = 0.07, size = 31, normalized size = 0.62 \begin {gather*} - \frac {i x}{8} + \frac {e^{4 i x}}{32} - \frac {e^{2 i x}}{16} - \frac {e^{- 2 i x}}{16} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)**2/(I+tan(x)),x)

[Out]

-I*x/8 + exp(4*I*x)/32 - exp(2*I*x)/16 - exp(-2*I*x)/16

________________________________________________________________________________________

Giac [A]
time = 0.42, size = 41, normalized size = 0.82 \begin {gather*} -\frac {i \, \tan \left (x\right )^{2} + 3 \, \tan \left (x\right ) + 2 i}{8 \, {\left (\tan \left (x\right ) + i\right )}^{2} {\left (\tan \left (x\right ) - i\right )}} + \frac {1}{16} \, \log \left (\tan \left (x\right ) + i\right ) - \frac {1}{16} \, \log \left (\tan \left (x\right ) - i\right ) \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2/(I+tan(x)),x, algorithm="giac")

[Out]

-1/8*(I*tan(x)^2 + 3*tan(x) + 2*I)/((tan(x) + I)^2*(tan(x) - I)) + 1/16*log(tan(x) + I) - 1/16*log(tan(x) - I)

________________________________________________________________________________________

Mupad [B]
time = 3.75, size = 35, normalized size = 0.70 \begin {gather*} -\frac {x\,1{}\mathrm {i}}{8}+\frac {\frac {{\mathrm {tan}\left (x\right )}^2}{8}-\frac {\mathrm {tan}\left (x\right )\,3{}\mathrm {i}}{8}+\frac {1}{4}}{{\left (\mathrm {tan}\left (x\right )+1{}\mathrm {i}\right )}^2\,\left (1+\mathrm {tan}\left (x\right )\,1{}\mathrm {i}\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(x)^2/(tan(x) + 1i),x)

[Out]

(tan(x)^2/8 - (tan(x)*3i)/8 + 1/4)/((tan(x) + 1i)^2*(tan(x)*1i + 1)) - (x*1i)/8

________________________________________________________________________________________